package org.dtrd.modules.record.entity.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.extern.slf4j.Slf4j;
import org.dtrd.common.util.DateUtils;
import org.dtrd.modules.record.entity.bean.InsulinRecordBean;

import javax.persistence.*;
import java.text.ParseException;
import java.util.Date;

@Slf4j
@Table(name = "dtrd_ent_rd_signin_insulin")
public class DtrdEntRdSigninInsulin {
    @Id
    @Column(name = "data_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(type = IdType.AUTO)
    private Integer dataId;

    @Column(name = "patient_id")
    private Integer patientId;

    /**
     * 记录日期
     */
    @Column(name = "record_date")
    private Date recordDate;

    /**
     * 记录时间
     */
    @Column(name = "record_time")
    private Date recordTime;

    /**
     * 胰岛素剂量描述
     */
    @Column(name = "insulin_describe")
    private String insulinDescribe;

    @Column(name = "insulin_injection")
    private Integer insulinInjection;

    /**
     * 备注
     */
    @Column(name = "insulin_remark")
    private String insulinRemark;

    @Column(name = "create_time")
    private Date createTime;

    @Column(name = "is_del")
    private Integer isDel;

    /**
     * 照片以 竖线 | 拼接
     */
    @Column(name = "record_photo")
    private String recordPhoto;

    /**
     * 1-早,2-午,3-晚,4-睡前
     */
    @Column(name = "insulin_type")
    private Integer insulinType;

    /**
     * 记录类型, 0-打卡, 1-建档
     */
    private Integer insulinRecordArchiveTag;

    public Integer getInsulinRecordArchiveTag() {
        return insulinRecordArchiveTag;
    }

    public void setInsulinRecordArchiveTag(Integer insulinRecordArchiveTag) {
        this.insulinRecordArchiveTag = insulinRecordArchiveTag;
    }

    /**
     * @return data_id
     */
    public Integer getDataId() {
        return dataId;
    }

    /**
     * @param dataId
     */
    public void setDataId(Integer dataId) {
        this.dataId = dataId;
    }

    /**
     * @return patient_id
     */
    public Integer getPatientId() {
        return patientId;
    }

    /**
     * @param patientId
     */
    public void setPatientId(Integer patientId) {
        this.patientId = patientId;
    }

    /**
     * 获取记录日期
     *
     * @return record_date - 记录日期
     */
    public Date getRecordDate() {
        return recordDate;
    }

    /**
     * 设置记录日期
     *
     * @param recordDate 记录日期
     */
    public void setRecordDate(Date recordDate) {
        this.recordDate = recordDate;
    }

    /**
     * 获取记录时间
     *
     * @return record_time - 记录时间
     */
    public Date getRecordTime() {
        return recordTime;
    }

    /**
     * 设置记录时间
     *
     * @param recordTime 记录时间
     */
    public void setRecordTime(Date recordTime) {
        this.recordTime = recordTime;
    }

    /**
     * 获取胰岛素剂量描述
     *
     * @return insulin_describe - 胰岛素剂量描述
     */
    public String getInsulinDescribe() {
        return insulinDescribe;
    }

    /**
     * 设置胰岛素剂量描述
     *
     * @param insulinDescribe 胰岛素剂量描述
     */
    public void setInsulinDescribe(String insulinDescribe) {
        this.insulinDescribe = insulinDescribe;
    }

    /**
     * 获取 备注
     *
     * @return insulin_remark -  备注
     */
    public String getInsulinRemark() {
        return insulinRemark;
    }

    /**
     * 设置 备注
     *
     * @param insulinRemark 备注
     */
    public void setInsulinRemark(String insulinRemark) {
        this.insulinRemark = insulinRemark;
    }

    /**
     * @return create_time
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @param createTime
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @return is_del
     */
    public Integer getIsDel() {
        return isDel;
    }

    /**
     * @param isDel
     */
    public void setIsDel(Integer isDel) {
        this.isDel = isDel;
    }

    /**
     * 获取照片以 竖线 | 拼接
     *
     * @return record_photo - 照片以 竖线 | 拼接
     */
    public String getRecordPhoto() {
        return recordPhoto;
    }

    /**
     * 设置照片以 竖线 | 拼接
     *
     * @param recordPhoto 照片以 竖线 | 拼接
     */
    public void setRecordPhoto(String recordPhoto) {
        this.recordPhoto = recordPhoto;
    }

    /**
     * 1-早,2-午,3-晚,4-睡前
     *
     * @return
     */
    public Integer getInsulinType() {
        return insulinType;
    }

    /**
     * 1-早,2-午,3-晚,4-睡前
     *
     * @param insulinType
     */
    public void setInsulinType(Integer insulinType) {
        this.insulinType = insulinType;
    }

    public Integer getInsulinInjection() {
        return insulinInjection;
    }

    public void setInsulinInjection(Integer insulinInjection) {
        this.insulinInjection = insulinInjection;
    }

    public DtrdEntRdSigninInsulin init() {
        isDel = 0;
        createTime = new Date();
        return this;
    }

    public DtrdEntRdSigninInsulin parseFromDTO(InsulinRecordBean dto) {
        dataId = dto.getDataId();
        patientId = dto.getPatientId();
        try {
            if (dto.getRecordTime() != null) {
                recordTime = DateUtils.parseDate(dto.getRecordTime(), DateUtils.datetimeFormat.get().toPattern());
                recordDate = DateUtils.parseDate(dto.getRecordTime(), DateUtils.date_sdf.get().toPattern());
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        recordPhoto = dto.getRecordPhoto();
        insulinType = dto.getInsulinType();
        insulinDescribe = dto.getInsulinDescribe();
        insulinRemark = dto.getInsulinRemark();
        insulinInjection=dto.getInjection();
        return this;
    }


    @Override
    public String toString() {
        return "DtrdEntRdSigninInsulin{" +
                "dataId=" + dataId +
                ", patientId=" + patientId +
                ", recordDate=" + recordDate +
                ", recordTime=" + recordTime +
                ", insulinDescribe='" + insulinDescribe + '\'' +
                ", insulinInjection=" + insulinInjection +
                ", insulinRemark='" + insulinRemark + '\'' +
                ", insulinType=" + insulinType +
                ", insulinRecordArchiveTag=" + insulinRecordArchiveTag +
                '}';
    }
}